"""
@Time    : 11/15/18 3:44 PM
@Author  : chengyue_he
"""


def req_data(request):
    """
    Get request data based on request.method and request.mimetype

    Returns:
        A regular dict which can be modified(scheme will modify data
        on validating)
    """
    if request.method in ['GET', 'DELETE']:
        return request.args.to_dict()
    else:
        if request.mimetype == 'application/json':
            data = request.get_json()
            return data
        else:
            return request.form.to_dict()

